#include <opencv2/opencv.hpp>
#include <iostream>

int main() {
    std::cout << "测试可用的摄像头设备..." << std::endl;
    
    // 测试摄像头ID 0-5
    for(int i = 0; i < 6; i++) {
        cv::VideoCapture cap(i);
        if(cap.isOpened()) {
            std::cout << "摄像头 " << i << " 可用" << std::endl;
            
            // 尝试读取一帧
            cv::Mat frame;
            if(cap.read(frame)) {
                std::cout << "摄像头 " << i << " 可以读取帧，尺寸: " 
                         << frame.cols << "x" << frame.rows << std::endl;
            } else {
                std::cout << "摄像头 " << i << " 无法读取帧" << std::endl;
            }
            cap.release();
        } else {
            std::cout << "摄像头 " << i << " 不可用" << std::endl;
        }
    }
    
    return 0;
}
